<template>
    <div>
        <div class="nav">
            <div class="back-btn">
                <span>
                    <svg width="1em" height="1em" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"
                        data-icon="LeftOutlined">
                        <path
                            d="M16.293 2.293a1 1 0 0 1 0 1.414L8 12l8.293 8.293a1 1 0 0 1-1.414 1.414l-8.293-8.293a2 2 0 0 1 0-2.828l8.293-8.293a1 1 0 0 1 1.414 0Z"
                            fill="currentColor"></path>
                    </svg> 
                </span>
            </div>
            <div class="approval-title">
                <div class="approval-name">{{ form.name }}</div>
            </div>
            <div class="tab-list">
                <div class="tab-list-item" @click="tabActive = '基础信息'"
                    :class="{ 'tab-list-item-active': tabActive == '基础信息' }">
                    <span class="counter">1</span>
                    <span>基础信息</span>
                </div>
                <div class="tab-list-item" @click="tabActive = '表单设计'"
                    :class="{ 'tab-list-item-active': tabActive == '表单设计' }">
                    <span class="counter">2</span>
                    <span>表单设计</span>
                </div>
                <div class="tab-list-item" @click="tabActive = '流程设计'"
                    :class="{ 'tab-list-item-active': tabActive == '流程设计' }">
                    <span class="counter">3</span>
                    <span>流程设计</span>
                </div>
                <div class="tab-list-item" @click="tabActive = '更多设置'"
                    :class="{ 'tab-list-item-active': tabActive == '更多设置' }">
                    <span class="counter">4</span>
                    <span>更多设置</span>
                </div>
            </div>
            <div class="nav-right">
                <button class="fz-btn">预览</button>
                <button class="fz-btn primary" @click="getFormJson">发布</button>
            </div>
        </div>
        <ApprovalForm :form-data="form" v-show="tabActive === '基础信息'" />
        <FormDesigner :form-items="form.items" v-show="tabActive === '表单设计'" />
        <FlowDesigner v-show="tabActive === '流程设计'"></FlowDesigner>
        <FlowDesigner2 v-show="tabActive === '更多设置'"></FlowDesigner2>
    </div>
</template>
<script>
import ApprovalForm from './ApprovalForm.vue'
import FormDesigner from './formdesigner/FormDesigner.vue'
import FlowDesigner from './flowdesigner/flowDesigner.vue'
import FlowDesigner2 from './flowdesigner/flowDesigner2.vue'
export default {
    name: 'App',
    components: {
        ApprovalForm,
        FormDesigner,
        FlowDesigner,
        FlowDesigner2
    },
    data() {
        return {
            tabActive: "流程设计",
            form: {
                name: "收款单",
                note: null,
                group: null,
                submitters: [],
                show: true,
                disableAdminData: false,
                items:[]
            }
        }
    },
    methods:{
        getFormJson(){
            console.log(JSON.stringify(this.form))
        }
    }
}
</script>
<style scoped>
/* nav */
.nav {
    display: flex;
    justify-content: start;
    align-items: center;
    height: 64px;
    position: relative;
    box-shadow: 0 1px 6px 0 rgba(0, 0, 0, .06);
    padding-left: 16px;
    padding-right: 20px;
    background-color: #fff;
}

.back-btn {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    height: 100%;
    margin-right: 15px;
}

.approval-title {
    width: calc(50% - 310.5px);
}

.approval-name {
    font-weight: 500;
    font-size: 16px;
    white-space: nowrap;
    cursor: pointer;
    width: -webkit-fit-content;
    width: -moz-fit-content;
    width: fit-content;
    max-width: 100%;
    height: 24px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tab-list {
    margin-left: 10px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
}

.tab-list .tab-list-item {
    font-family: PingFang SC, Microsoft YaHei;
    font-size: 18px;
    line-height: 28px;
    color: #646a73;
    margin-right: 42px;
    padding: 18px 0;
    border-bottom: 2px solid transparent;
    cursor: pointer;
}

.tab-list .tab-list-item .counter {
    display: inline-block;
    margin-right: 6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid #646a73;
    font-size: 16px;
    line-height: 22px;
    text-align: center;
}

.tab-list .tab-list-item-active {
    border-bottom-color: #3370ff;
    color: #3370ff;
    font-weight: 500;
}

.tab-list .tab-list-item-active .counter {
    border-color: #3370ff;
    background-color: #3370ff;
    color: #fff;
    font-weight: 400;
}

.nav-right {
    flex: 1 1;
    flex-shrink: 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    position: relative;
    height: 100%;
    width: fit-content;

}

.nav-right .primary {
    margin-left: 10px;
}

/* nav end */
.box {
    margin: 0 auto;
    padding: 24px 0;
    height: 100%;
    /* text-align: center; */
    overflow-y: auto;

    position: relative;
}

.panel {
    display: inline-block;
    padding: 24px 288px;
    background-color: #fff;
    text-align: left;
}

.form-item {
    position: relative;
    display: block;
    margin-bottom: 24px;
}

.form-item-label {
    margin-bottom: 8px;
    font-family: PingFang SC, Microsoft YaHei;
    font-size: 14px;
    line-height: 20px;
    color: #1f2329;
}

.required {
    color: red;
}

.form-item .form-item-content {
    font-family: PingFang SC, Microsoft YaHei;
}

.form-item .form-item-content .logo {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
}

.logo-selector {
    display: flex;
    align-items: center;
}

.logo-selector .logo img {
    width: 100%;
    height: 100%;
}
</style>